<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="药品名称" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入药品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="实际销售单价" prop="actualSalesUnitPrice">
        <el-input
          v-model="queryParams.actualSalesUnitPrice"
          placeholder="请输入实际销售单价"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="主治功能" prop="indicativeFunctions">
        <el-input
          v-model="queryParams.indicativeFunctions"
          placeholder="请输入主治功能"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所属药房" prop="pharmacyId">
        <el-select v-model="queryParams.pharmacyId" placeholder="请选择">
          <el-option
            v-for="item in pharmacyList"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="运费" prop="shippingFee">
        <el-input
          v-model="queryParams.shippingFee"
          placeholder="请输入运费"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生产企业" prop="manufacturingEnterprise">
        <el-input
          v-model="queryParams.manufacturingEnterprise"
          placeholder="请输入生产企业"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="药品性状" prop="drugShape">
        <el-input
          v-model="queryParams.drugShape"
          placeholder="请输入药品性状"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="贮藏条件" prop="storageConditions">
        <el-input
          v-model="queryParams.storageConditions"
          placeholder="请输入贮藏条件"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="包装" prop="packages">
        <el-input
          v-model="queryParams.packages"
          placeholder="请输入包装"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="剂型" prop="dosageForm">
        <el-input
          v-model="queryParams.dosageForm"
          placeholder="请输入剂型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="批准文号" prop="approvalNo">
        <el-input
          v-model="queryParams.approvalNo"
          placeholder="请输入批准文号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="药品类型" prop="typeId">
        <el-select v-model="queryParams.typeId" placeholder="请选择药品类型">
          <el-option
            v-for="item in typeList"
            :key="item.id"
            :label="item.name"
            :value="item.id">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="库存" prop="inventory">
        <el-input
          v-model="queryParams.inventory"
          placeholder="请输入库存"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="销量" prop="salesVolume">
        <el-input
          v-model="queryParams.salesVolume"
          placeholder="请输入销量"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="生产日期" prop="dateOfManufacture">
        <el-date-picker clearable
                        v-model="queryParams.dateOfManufacture"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择生产日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="有效期" prop="periodOfValidity">
        <el-input
          v-model="queryParams.periodOfValidity"
          placeholder="请输入有效期"
          clearable
          @keyup.enter.native="handleQuery"
        />年
      </el-form-item>

      <el-form-item label="过期状态" prop="pastDue">
        <el-input
          v-model="queryParams.pastDue"
          placeholder="请输入过期状态"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8" >
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['medicine:medicine:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['medicine:medicine:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table
      :data="medicineList"
      style="width: 100%">
<!--      <el-table-column-->
<!--        label="编号"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.id }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
        label="药品名称"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.name }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="图片"
        width="180">
        <template slot-scope="scope">
          <el-image
            style="width: 100px; height: 100px"
            :src="scope.row.pic.split(',')[0]"
            ></el-image>
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--        label="单价"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.price }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
        label="实际销售单价"
        width="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.actualSalesUnitPrice }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="主治功能"
        width="180">
        <template slot-scope="scope" v-if="null != scope.row.indicativeFunctions ">
          <span style="margin-left: 10px" >{{ scope.row.indicativeFunctions }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="用法用量"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.usagAndDosage }}</span>
        </template>
      </el-table-column>

      <el-table-column
        label="所属药房"
        width="150">
        <template slot-scope="scope">
          <span style="margin-left: 5px">{{scope.row.pharmacyName}}</span>
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--        label="药品规格"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.sku }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="运费"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.shippingFee }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
        label="生产企业"
        width="180">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.manufacturingEnterprise }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column-->
<!--        label="药品成分"-->
<!--        width="180">-->
<!--        <template slot-scope="scope" v-if="null != scope.row.drugIngredients">-->
<!--          <span style="margin-left: 10px" v-if="scope.row.drugIngredients.length > 30">{{ scope.row.drugIngredients.slice(0, 30) + '***' }}</span>-->
<!--          <span style="margin-left: 10px" v-else>{{ scope.row.drugIngredients }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="用药禁忌"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.contraindications }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="药品性状"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.drugShape }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="不良反应"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.adverseReactions }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="相互作用"-->
<!--        width="180">-->
<!--        <template slot-scope="scope" v-if="null != scope.row.interact ">-->
<!--          <span style="margin-left: 10px" v-if="scope.row.interact.length > 30">{{ scope.row.interact.slice(0, 30) + '***' }}</span>-->
<!--          <span style="margin-left: 10px" v-else>{{ scope.row.interact }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="贮藏条件"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.storageConditions }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="包装"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.packages }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="剂型"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.dosageForm }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="注意事项"-->
<!--        width="180">-->
<!--        <template slot-scope="scope" v-if="null != scope.row.precautions ">-->
<!--          <span style="margin-left: 10px" v-if="scope.row.precautions.length > 30">{{ scope.row.precautions.slice(0, 30) + '***' }}</span>-->
<!--          <span style="margin-left: 10px" v-else>{{ scope.row.precautions }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
<!--      <el-table-column-->
<!--        label="批准文号"-->
<!--        width="180">-->
<!--        <template slot-scope="scope">-->
<!--          <span style="margin-left: 10px">{{ scope.row.approvalNo }}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column
        label="药品类型"
        width="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.typeName }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="库存"
        width="100">
        <template slot-scope="scope">
          <span style="margin-left: 5px">{{ scope.row.inventory }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="销量"
        width="100">
        <template slot-scope="scope">
          <span style="margin-left: 10px">{{ scope.row.salesVolume }}</span>
        </template>
      </el-table-column>
      <el-table-column label="生产日期" align="center" prop="dateOfManufacture" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dateOfManufacture, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="有效期(年)" width="100" align="center" prop="periodOfValidity" />
      <el-table-column label="排序字段" width="100" align="center" prop="sort" />
      <el-table-column label="上架状态" align="center" width="100" prop="statusName" />
<!--      <el-table-column label="过期状态" align="center" prop="pastDueName" />-->
      <el-table-column label="操作">
        <template slot-scope="scope" width="500px">
          <el-button
            size="mini"
            @click="updateStatusById(scope.row.id,1)" v-if="0 == scope.row.status">上架</el-button>
          <el-button
            size="mini"
            @click="updateStatusById(scope.row.id,0)" v-if="1 == scope.row.status">下架</el-button>
          <el-button
            size="mini"
            @click="showDetail(scope.row)">详情</el-button>
          <el-button
            size="mini"
            @click="handleUpdate(scope.row)">编辑</el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改药品对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-steps :active="active" finish-status="success">
          <el-step title="步骤 1" icon="el-icon-edit"></el-step>
          <el-step title="步骤 2" icon="el-icon-upload"></el-step>
          <el-step title="步骤 3" icon="el-icon-picture"></el-step>
        </el-steps>
        <div v-if="0==active">
          <el-form-item label="药品名称" prop="name">
            <el-input v-model="form.name" placeholder="请输入药品名称" />
          </el-form-item>
          <el-form-item label="图片" prop="pic">
<!--            <image-upload v-model="form.pic" :uploadType="1"/>-->
            <el-upload
              action="/dev-api/medicine/medicine/upload"
              list-type="picture-card"
              :on-success="handleSuccess"
              :on-preview="handlePictureCardPreview"
              :on-remove="handleRemove">
              <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogVisible">
              <img width="100%" :src="dialogImageUrl" alt="">
            </el-dialog>
          </el-form-item>
          <el-form-item label="单价" prop="price">
            <el-input v-model="form.price" placeholder="请输入单价" />
          </el-form-item>
          <el-form-item label="实际销售单价" prop="actualSalesUnitPrice">
            <el-input v-model="form.actualSalesUnitPrice" placeholder="请输入实际销售单价" />
          </el-form-item>
          <el-form-item label="药品规格" prop="sku">
            <el-input v-model="form.sku" placeholder="请输入药品规格" />
          </el-form-item>
          <el-form-item label="运费" prop="shippingFee">
            <el-input v-model="form.shippingFee" placeholder="请输入运费" />
          </el-form-item>
          <el-form-item label="所属药房" prop="pharmacyId">
            <el-select v-model="form.pharmacyId" placeholder="请选择">
              <el-option
                v-for="item in pharmacyList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="库存" prop="inventory">
            <el-input v-model="form.inventory" placeholder="请输入库存" />
          </el-form-item>
          <el-form-item label="生产企业" prop="manufacturingEnterprise">
            <el-input v-model="form.manufacturingEnterprise" placeholder="请输入生产企业" />
          </el-form-item>
        </div>
        <div v-if="1==active">
          <el-form-item label="主治功能" prop="indicativeFunctions">
            <el-input v-model="form.indicativeFunctions" placeholder="请输入主治功能" />
          </el-form-item>
          <el-form-item label="用法用量" prop="usagAndDosage">
            <el-input v-model="form.usagAndDosage" placeholder="请输入用法用量" />
          </el-form-item>
          <el-form-item label="药品成分" prop="drugIngredients">
            <el-input v-model="form.drugIngredients" placeholder="请输入药品成分" />
          </el-form-item>
          <el-form-item label="用药禁忌" prop="contraindications">
            <el-input v-model="form.contraindications" placeholder="请输入用药禁忌" />
          </el-form-item>
          <el-form-item label="药品性状" prop="drugShape">
            <el-input v-model="form.drugShape" placeholder="请输入药品性状" />
          </el-form-item>
          <el-form-item label="不良反应" prop="adverseReactions">
            <el-input v-model="form.adverseReactions" placeholder="请输入不良反应" />
          </el-form-item>
        </div>
        <div v-if="2==active">
          <el-form-item label="相互作用" prop="interact">
            <el-input v-model="form.interact" placeholder="请输入相互作用" />
          </el-form-item>
          <el-form-item label="贮藏条件" prop="storageConditions">
            <el-input v-model="form.storageConditions" placeholder="请输入贮藏条件" />
          </el-form-item>
          <el-form-item label="包装" prop="packages">
            <el-input v-model="form.packages" placeholder="请输入包装" />
          </el-form-item>
          <el-form-item label="剂型" prop="dosageForm">
            <el-input v-model="form.dosageForm" placeholder="请输入剂型" />
          </el-form-item>
          <el-form-item label="注意事项" prop="precautions">
            <el-input v-model="form.precautions" type="textarea" placeholder="请输入内容" />
          </el-form-item>
        </div>
        <div v-if="3==active">
          <el-form-item label="批准文号" prop="approvalNo">
            <el-input v-model="form.approvalNo" placeholder="请输入批准文号" />
          </el-form-item>
          <el-form-item label="药品类型" prop="typeId">
            <el-select v-model="form.typeId" placeholder="请选择药品类型">
              <el-option
                v-for="item in typeList"
                :key="item.id"
                :label="item.name"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="生产日期" prop="dateOfManufacture">
            <el-date-picker clearable
                            v-model="form.dateOfManufacture"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="请选择生产日期">
            </el-date-picker>
          </el-form-item>
          <el-form-item label="有效期" prop="periodOfValidity">
            <el-input v-model="form.periodOfValidity" placeholder="请输入有效期" />
          </el-form-item>
          <el-form-item label="排序" prop="sort">
            <el-input v-model="form.sort" placeholder="请输入排序" />
          </el-form-item>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button style="margin-top: 12px;" @click="next">下一步</el-button>
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMedicine, getMedicine, delMedicine, addMedicine, updateMedicine } from "@/api/medicine/medicine";
import { allPharmacyList} from "@/api/medicine/pharmacy";
import {allTypeList} from "@/api/medicine/type";
import {updateStatus} from "@/api/doctor/doctor";
import AES from "@/utils/AES";

export default {
  name: "Medicine",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 药品表格数据
      medicineList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      active: 0,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        name: null,
        pic: [],
        price: null,
        actualSalesUnitPrice: null,
        indicativeFunctions: null,
        usagAndDosage: null,
        pharmacyId: null,
        sku: null,
        shippingFee: null,
        manufacturingEnterprise: null,
        drugIngredients: null,
        contraindications: null,
        drugShape: null,
        adverseReactions: null,
        interact: null,
        storageConditions: null,
        packages: null,
        dosageForm: null,
        precautions: null,
        approvalNo: null,
        typeId: null,
        inventory: null,
        salesVolume: null,
        dateOfManufacture: null,
        periodOfValidity: null,
        lastUpdateTime: null,
        state: null,
        sort: null,
        deletedFlag: null,
        status: null,
        pastDue: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      },
      dialogImageUrl: '',
      dialogVisible: false,
      pharmacyList: [],
      typeList: [],
      images: ''
    };
  },
  created() {
    this.getList();
    this.getPharmacyList()
    this.getTypeList()
  },
  methods: {
    updateStatusById(id,status){
      this.reset();
      this.form.id = id;
      this.form.status = status
      updateMedicine(this.form).then(res => {
        if (0==status){
          this.$modal.msgSuccess("下架成功");
        }
        if (1==status){
          this.$modal.msgSuccess("上架成功");
        }
        this.reset();
        this.getList();
      })
    },
    getPharmacyList(){
      allPharmacyList().then(res => {
        this.pharmacyList = res.data
      })
    },
    getTypeList(){
      allTypeList().then(res => {
        this.typeList = res.data
      })
    },
    handleSuccess(response){
      let decrypt = AES.decrypt(response);
      this.images += JSON.parse(decrypt).data+','
      // this.images += response.data + ','
      // this.form.pic = response.data
      console.log("------------------图片"+decrypt)
      console.log(JSON.parse(decrypt).data)
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    next() {
      if (this.active++ > 2) this.active = 0;
    },
    /** 查询药品列表 */
    getList() {
      this.loading = true;
      listMedicine(this.queryParams).then(response => {
        this.medicineList = response.data.rows;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        name: null,
        pic: null,
        price: null,
        actualSalesUnitPrice: null,
        indicativeFunctions: null,
        usagAndDosage: null,
        pharmacyId: null,
        sku: null,
        shippingFee: null,
        manufacturingEnterprise: null,
        drugIngredients: null,
        contraindications: null,
        drugShape: null,
        adverseReactions: null,
        interact: null,
        storageConditions: null,
        packages: null,
        dosageForm: null,
        precautions: null,
        approvalNo: null,
        typeId: null,
        inventory: null,
        salesVolume: null,
        dateOfManufacture: null,
        periodOfValidity: null,
        createTime: null,
        createBy: null,
        lastUpdateTime: null,
        updateBy: null,
        state: null,
        sort: null,
        deletedFlag: null,
        status: null,
        pastDue: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加药品";
    },
    /** 商品详情 */
    showDetail(row) {
      this.reset();
      const id = row.id
      this.$router.push({ name: 'ShowDetail', query: { id: id } })
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      console.log("id"+id)
      getMedicine(id).then(response => {
        this.form = response.data;
        this.form.pic = response.data.pic;
        this.open = true;
        this.title = "修改药品";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.form.pic = this.images.substring(',')
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateMedicine(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMedicine(this.form).then(response => {
              if (200 == response.code){
                console.log("打印"+response.data)
                this.$modal.msgSuccess("新增成功");
                this.open = false;
                this.getList();
              }
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除药品编号为"' + ids + '"的数据项？').then(function() {
        return delMedicine(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('medicine/medicine/export', {
        ...this.queryParams
      }, `medicine_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
